<template>
  <div class="work-order-list">
   <el-card class="box-carddan">
     <!-- 顶部标签页 -->
     <el-tabs v-model="activeTab">
      <el-tab-pane label="全部" name="all"></el-tab-pane>
      <el-tab-pane label="我的工单" name="my"></el-tab-pane>
      <el-tab-pane label="我的验收" name="check"></el-tab-pane>
    </el-tabs>

    <!-- 操作按钮组 -->
    <div class="operation-bar">
      <div class="left-btns">
        <el-button type="success" size="small" @click="dan" >下发工单</el-button>
        <el-button type="success" size="small" @click="kuai">快速工单</el-button>
        <el-button size="small" plain>删除</el-button>
        <el-button size="small" plain>执行保养</el-button>
        <el-button size="small" plain>导出</el-button>
      </div>
      <div class="right-search">
        <el-input v-model="searchKey" placeholder="请输入内容搜索或主题" suffix-icon="el-icon-search" size="small">
          <i slot="suffix" class="el-input__icon el-icon-circle-close" @click="clearSearch">
          </i>
        </el-input>
      </div>
    </div>

    <!-- 表格 -->
    <el-table :data="tableData" style="width: 100%">
      <el-table-column type="selection" width="55" align="center" />
      </el-table-column>
      <el-table-column prop="id" label="序号" width="70" align="center">
      </el-table-column>
      <el-table-column label="操作" width="80" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="small" style="color: #00B42A" @click="handleView(scope.row)">
            查看
          </el-button>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态" width="100" align="center">
      </el-table-column>
      <el-table-column prop="orderNo" label="工单单号" width="120" align="center">
      </el-table-column>
      <el-table-column prop="title" label="工单主题" align="center">
      </el-table-column>
      <el-table-column prop="type" label="工单类型" width="150" align="center">
      </el-table-column>
      <el-table-column prop="team" label="保养组" width="150" align="center">
      </el-table-column>
      <el-table-column prop="maintainer" label="保养负责人" width="120" align="center">
      </el-table-column>
      <el-table-column prop="startTime" label="开始时间" width="160" align="center">
      </el-table-column>
      <el-table-column prop="endTime" label="结束时间" width="160" align="center">
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="pagination">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-sizes="[10, 20, 30, 50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
   </el-card>
  </div>
</template>

<script>
export default {
  name: 'WorkOrderList',
  data() {
    return {
      activeTab: 'my',
      searchKey: '',
      currentPage: 1,
      pageSize: 10,
      total: 45,
      tableData: [
        {
          id: 1,
          status: '待执行',
          orderNo: 'WO006',
          title: '传动皮带张力调整',
          type: '下发工单',
          team: '传动系统调整班组',
          maintainer: '周强',
          startTime: '2025-07-12 10:30',
          endTime: '2025-07-12 10:30'
        },
        // ... 更多数据
      ]
    }
  },
  methods: {
    handleView(val){
      this.$router.push({ path: "/equipment/maintenance/dan/cha2" });
    },
    kuai(){
      this.$router.push({ path: "/equipment/maintenance/dan/xin2" });
    },
    dan(){
      this.$router.push({ path: "/equipment/maintenance/dan/xin" });
    },
    clearSearch() {
      this.searchKey = ''
    },
    handleSizeChange(val) {
      this.pageSize = val
      // 重新加载数据
    },
    handleCurrentChange(val) {
      this.currentPage = val
      // 重新加载数据
    }
  }
}
</script>

<style scoped>
.box-carddan{
  width: 1200px;
  margin-left: 15px;
  margin-bottom: 20px;
}
.work-order-list {
  padding: 20px;
}

.operation-bar {
  margin: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.left-btns {
  display: flex;
  gap: 10px;
}

.right-search {
  width: 300px;
}

.pagination {
  margin-top: 20px;
  text-align: right;
}

/* 表格样式优化 */
:deep(.el-table th) {
  background-color: #f5f7fa;
  color: #606266;
}

:deep(.el-table td) {
  padding: 8px 0;
}

/* 响应式调整 */
@media screen and (max-width: 768px) {
  .work-order-list {
    padding: 10px;
  }

  .operation-bar {
    flex-direction: column;
    gap: 10px;
  }

  .right-search {
    width: 100%;
  }

  .el-table {
    width: 100%;
    overflow-x: auto;
  }
}
</style>
